'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _database = require('../config/database');

var _database2 = _interopRequireDefault(_database);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

const updateAgentGems = (() => {
  var _ref = _asyncToGenerator(function* (gem, accounts) {
    let sql = `
    UPDATE t_agent
    SET gems = ${gem}
    WHERE  accounts = ${accounts}
  `;
    try {
      yield _database2.default.query(sql);
      console.log('update t_agent success');
    } catch (err) {
      console.log(`update t_agent ${err}`);
    }
  });

  return function updateAgentGems(_x, _x2) {
    return _ref.apply(this, arguments);
  };
})();
const getAgentAccountsInfoById = (() => {
  var _ref2 = _asyncToGenerator(function* (accounts) {
    let accountsInfo = null;
    let sql = `SELECT * FROM t_agent
    WHERE accounts = ${accounts}`;
    try {
      accountsInfo = yield _database2.default.query(sql);
      // console.log("hahahah", accountsInfo)
    } catch (err) {
      console.log(`search yp_apply_order ${err}`);
    }
    return accountsInfo[0];
  });

  return function getAgentAccountsInfoById(_x3) {
    return _ref2.apply(this, arguments);
  };
})();

exports.default = {
  updateAgentGems,
  getAgentAccountsInfoById
};